﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Kaidou.Model;
using Kaidou.Persister;
using Kaidou.Util;

public partial class master_master_union_delete_conf : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        LoginModel loginModel = (LoginModel)Session["loginModel"];

        if (loginModel == null)
        {
            Response.Redirect("../login.aspx");
        }
        else if (!loginModel.isOperator())
        {
            Response.Redirect("../menu.aspx");
        }

        if ("on".Equals(Resources.Resource.kaidou_view_user_clss))
        {
            user_clss_panel.Visible = true;
        }
        else
        {
            user_clss_panel.Visible = false;
        }

        string area = Resources.Resource.area;
        string[] areaArray = area.Split(',');

        MstUnion M = (MstUnion)Session["mstunion"];
        union_code.Text = M.Id.UnionCode;
        office_address.Text = M.OfficeAddress;
        office_city.Text = M.OfficeCity;
        office_email.Text = M.OfficeEmail;
        office_fax.Text = M.OfficeFax;
        office_kana.Text = M.OfficeKana;
        office_name.Text = M.OfficeName;
        office_pref_code.Text = areaArray[M.OfficePrefCode-1];
        office_tel.Text = M.OfficeTel;
        office_zip_no.Text = M.OfficeZipNo;
        tanto_kana.Text = M.TantoKana;
        tanto_name.Text = M.TantoName;
        daihyo_name.Text = M.DaihyoName;
        daihyo_kana.Text = M.DaihyoKana;
        if (M.TraderRegNo != null && M.TraderRegNo.Trim().Length > 0)
        {
            trader_reg_no.Text = M.TraderRegNo.Substring(0, 2) + "-" + M.TraderRegNo.Substring(2, 5); ;
        }
       
        user_clss.Text = int.Parse(M.UserClss) == 10 ? "組合員" : int.Parse(M.UserClss) == 20 ? "事務局" : "オペレータ";
    }

    protected void delete_confirm(object sender, EventArgs e) {
        MST_UnionPersister dao = new MST_UnionPersister();
        MstUnion M = (MstUnion)Session["mstunion"];
        try
        {
            dao.deleteMasterUnion(M);
        }
        catch(Exception ee)
        {
            LogManager.error("master_master_union_delete_conf - delete_confirm "+ee.Message);
        }

        Session["back"] = 1;
        Response.Redirect("master_union_search.aspx");
    
    }
}
